<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>视频直播 | 欢迎来到小张的博客</title><meta name="keywords" content="vue"><meta name="author" content="Z_SiTong"><meta name="copyright" content="Z_SiTong"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="直播 直播：流式传输协议，传输非常短的一小截视频 观看直播 浏览器：video标签 客户端工具：vlc播放器   协议 rtmp协议   推流（使用OBS） 将现场的视频信号传到网络的过程，对网络要求比较高 OBS下载地址：https:&#x2F;&#x2F;obsproject.com&#x2F;zh-cn   拉流（使用浏览器或Vlc） 服务器已有直播内容，根据协议类型（如RTMP、RTP、RTSP、HTTP等），与服务器">
<meta property="og:type" content="article">
<meta property="og:title" content="视频直播">
<meta property="og:url" content="https://zhang-sitong.gitee.io/blogs/lz_12/index.html">
<meta property="og:site_name" content="欢迎来到小张的博客">
<meta property="og:description" content="直播 直播：流式传输协议，传输非常短的一小截视频 观看直播 浏览器：video标签 客户端工具：vlc播放器   协议 rtmp协议   推流（使用OBS） 将现场的视频信号传到网络的过程，对网络要求比较高 OBS下载地址：https:&#x2F;&#x2F;obsproject.com&#x2F;zh-cn   拉流（使用浏览器或Vlc） 服务器已有直播内容，根据协议类型（如RTMP、RTP、RTSP、HTTP等），与服务器">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/02/05/tKdkzYVFgSc7J8A.jpg">
<meta property="article:published_time" content="2019-02-05T12:19:00.000Z">
<meta property="article:modified_time" content="2021-03-23T01:16:12.844Z">
<meta property="article:author" content="Z_SiTong">
<meta property="article:tag" content="vue">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/02/05/tKdkzYVFgSc7J8A.jpg"><link rel="shortcut icon" href="/blogs/img/favicon.png"><link rel="canonical" href="https://zhang-sitong.gitee.io/blogs/lz_12/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/blogs/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/blogs/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
};

const saveToLocal = {
  // ttl 單位是 天
  set: function setWithExpiry(key, value, ttl) {
    if (ttl === 0) return
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}

// https://stackoverflow.com/questions/16839698/jquery-getscript-alternative-in-native-javascript
const getScript = url => new Promise((resolve, reject) => {
  const script = document.createElement('script')
  script.src = url
  script.async = true
  script.onerror = reject
  script.onload = script.onreadystatechange = function() {
    const loadState = this.readyState
    if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
    script.onload = script.onreadystatechange = null
    resolve()
  }
  document.head.appendChild(script)
})</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-03-23 09:16:12'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
   if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }
  const autoChangeMode = 'false'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
   if (asideStatus === 'hide') {
     document.documentElement.classList.add('hide-aside')
   } else {
     document.documentElement.classList.remove('hide-aside')
   }
}})()</script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><div class="aplayer" data-id="6583040939" data-server="netease" data-type="playlist" data-fixed="true" data-listFolded="false" data-order="random" data-preload="auto"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lete114/CDN/music/APlayer/APlayer.min.css"><script src="https://cdn.jsdelivr.net/gh/lete114/CDN/music/APlayer/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/meting@1.2.0/dist/Meting.min.js"></script><meta name="generator" content="Hexo 5.3.0"><link rel="alternate" href="/blogs/atom.xml" title="欢迎来到小张的博客" type="application/atom+xml">
</head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="/blogs/img/%E5%8D%9A%E5%AE%A2%E5%A4%B4%E5%83%8F.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/blogs/archives/"><div class="headline">文章</div><div class="length-num">29</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blogs/tags/"><div class="headline">标签</div><div class="length-num">12</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blogs/categories/"><div class="headline">分类</div><div class="length-num">12</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blogs/"><i class="fa-fw fa fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/archives/"><i class="fa-fw fa fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/link/"><i class="fa-fw fa fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/about/"><i class="fa-fw fa fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://i.loli.net/2021/02/05/tKdkzYVFgSc7J8A.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blogs/">欢迎来到小张的博客</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blogs/"><i class="fa-fw fa fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/archives/"><i class="fa-fw fa fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/link/"><i class="fa-fw fa fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/blogs/about/"><i class="fa-fw fa fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">视频直播</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="fa-fw post-meta-icon far fa-calendar-alt"></i><span class="post-meta-label">发表于</span><time datetime="2019-02-05T12:19:00.000Z" title="undefined 2019-02-05 20:19:00">2019-02-05</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blogs/categories/Vue/">Vue</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="直播"><a href="#直播" class="headerlink" title="直播"></a>直播</h2><ul>
<li><h3 id="直播：流式传输协议，传输非常短的一小截视频"><a href="#直播：流式传输协议，传输非常短的一小截视频" class="headerlink" title="直播：流式传输协议，传输非常短的一小截视频"></a>直播：流式传输协议，传输非常短的一小截视频</h3></li>
<li><h3 id="观看直播"><a href="#观看直播" class="headerlink" title="观看直播"></a>观看直播</h3><ul>
<li>浏览器：video标签</li>
<li>客户端工具：vlc播放器</li>
</ul>
</li>
<li><h3 id="协议"><a href="#协议" class="headerlink" title="协议"></a>协议</h3><ul>
<li>rtmp协议</li>
</ul>
</li>
<li><h3 id="推流（使用OBS）"><a href="#推流（使用OBS）" class="headerlink" title="推流（使用OBS）"></a>推流（使用OBS）</h3><ul>
<li>将现场的视频信号传到网络的过程，对网络要求比较高</li>
<li><strong>OBS下载地址</strong>：<a target="_blank" rel="noopener" href="https://obsproject.com/zh-cn">https://obsproject.com/zh-cn</a></li>
</ul>
</li>
<li><h3 id="拉流（使用浏览器或Vlc）"><a href="#拉流（使用浏览器或Vlc）" class="headerlink" title="拉流（使用浏览器或Vlc）"></a>拉流（使用浏览器或Vlc）</h3><ul>
<li>服务器已有直播内容，根据协议类型（如RTMP、RTP、RTSP、HTTP等），与服务器建立连接并接收数据，进行拉取的过程</li>
<li><strong>Vlc下载地址</strong>：<a target="_blank" rel="noopener" href="https://www.videolan.org/vlc/">https://www.videolan.org/vlc/</a></li>
</ul>
</li>
</ul>
<h2 id="直播基本流程图"><a href="#直播基本流程图" class="headerlink" title="直播基本流程图"></a>直播基本流程图</h2><p><img src="https://i.loli.net/2021/02/05/Cfz3g426MyBaFJO.png" alt="视频直播流程.png"></p>
<h2 id="常见的直播协议"><a href="#常见的直播协议" class="headerlink" title="常见的直播协议"></a>常见的直播协议</h2><ul>
<li><h3 id="RTMP直播协议"><a href="#RTMP直播协议" class="headerlink" title="RTMP直播协议"></a>RTMP直播协议</h3><p>  <code>RTMP 是专为流媒体开发的协议，对底层的优化比其它协议更加优秀</code></p>
<ul>
<li><h3 id="优点"><a href="#优点" class="headerlink" title="优点"></a>优点</h3><blockquote>
<p>它对 Adobe Flash 支持好<br>基本上所有的编码器（摄像头之类）都支持 RTMP 输出<br>另外RTMP适合长时间播放，即 10 天多连续播放没有出现问题，稳定<br>最后 RTMP 的延迟<strong>相对较低</strong>，一般延时在 1-3s 之间，一般的视频会议，互动式直播，完全是够用的</p>
</blockquote>
</li>
<li><h3 id="缺点"><a href="#缺点" class="headerlink" title="缺点"></a>缺点</h3><blockquote>
<p>它是基于 TCP 传输，非公共端口，可能会被防火墙阻拦<br>RTMP 为 Adobe 私有协议，很多设备无法播放，兼容性不高<br>Html基础支持不好，无法直接使用HTML标签完成拉流</p>
</blockquote>
</li>
</ul>
</li>
<li><h3 id="HTTP-FLV直播协议"><a href="#HTTP-FLV直播协议" class="headerlink" title="HTTP-FLV直播协议"></a>HTTP-FLV直播协议</h3><p>  <code>FLV: 简单轻量、加载速度极快、播放快</code></p>
<ul>
<li><h3 id="优点-1"><a href="#优点-1" class="headerlink" title="优点"></a>优点</h3><blockquote>
<p>可以直接通过http协议进行传输，http属于公共协议，公共端口：80<br>支持加密，使用https<br>兼容移动端设备，比如：安卓、ios</p>
</blockquote>
</li>
<li><h3 id="缺点-1"><a href="#缺点-1" class="headerlink" title="缺点"></a>缺点</h3><blockquote>
<p>会缓存直播数据，保存直播传输过来的一段段flv文件，隐私保密不好<br>不能在大并发情况下使用</p>
</blockquote>
</li>
</ul>
</li>
<li><h3 id="HLS直播协议"><a href="#HLS直播协议" class="headerlink" title="HLS直播协议"></a>HLS直播协议</h3><p>  <code>苹果公司实现的基于 HTTP 的流媒体传输协议</code></p>
<ul>
<li><h3 id="优点-2"><a href="#优点-2" class="headerlink" title="优点"></a>优点</h3><blockquote>
<p>数据通过 HTTP 协议传输，所以采用 HLS 时不用考虑防火墙或者代理的问题。<br>使用短时长的分片文件来播放，客户端可以平滑的切换码率，以适应不同带宽条件下的播放。<br>HLS 是苹果推出的流媒体协议，在 iOS 平台上可以获得天然的支持，采用系统提供的 AVPlayer 就能直接播放，不用自己开发播放器</p>
</blockquote>
</li>
<li><h3 id="缺点-2"><a href="#缺点-2" class="headerlink" title="缺点"></a>缺点</h3><blockquote>
<p>通常 HLS 直播延时会达到 20-30s，而高延时对于需要实时互动体验的直播来说是不可接受的。<br>HLS 基于短连接 HTTP，HTTP 是基于 TCP 的，这就意味着 HLS 需要不断地与服务器建立连接，TCP 每次建立连接时的三次握手、慢启动过程、断开连接时的四次挥手都会产生消耗</p>
</blockquote>
</li>
</ul>
</li>
</ul>
<hr>
<h2 id="云主机搭建直播"><a href="#云主机搭建直播" class="headerlink" title="云主机搭建直播"></a>云主机搭建直播</h2><h3 id="环境部署相关"><a href="#环境部署相关" class="headerlink" title="环境部署相关"></a>环境部署相关</h3><ul>
<li><h3 id="创建软件的存储位置"><a href="#创建软件的存储位置" class="headerlink" title="创建软件的存储位置"></a>创建软件的存储位置</h3>  <figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mkdir /usr/local/nginx-flv</span><br><span class="line"><span class="comment">// 创建了一个安装目录</span></span><br><span class="line">mkdir /home/flv-tools</span><br><span class="line"><span class="comment">// 存储所需软件</span></span><br></pre></td></tr></table></figure></li>
<li><h3 id="下载nginx"><a href="#下载nginx" class="headerlink" title="下载nginx"></a>下载nginx</h3><pre><code>  高性能多路复用服务器，让你支持同时响应多个客户连接
  多线程、多进程开发模式</code></pre>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wget https:<span class="comment">//nginx.org/download/nginx-1.18.0.tar.gz</span></span><br></pre></td></tr></table></figure></li>
<li><h3 id="下载直播模块"><a href="#下载直播模块" class="headerlink" title="下载直播模块"></a>下载直播模块</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone https:<span class="comment">//github.com/winshining/nginx-http-flv-module</span></span><br></pre></td></tr></table></figure></li>
<li><h3 id="解压下载好的nginx"><a href="#解压下载好的nginx" class="headerlink" title="解压下载好的nginx"></a>解压下载好的nginx</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -zxvf nginx-<span class="number">1.18</span><span class="number">.0</span>.tar.gz nginx-<span class="number">1.18</span><span class="number">.0</span>/</span><br></pre></td></tr></table></figure></li>
<li><h3 id="解压下载好的rtmp直播模块"><a href="#解压下载好的rtmp直播模块" class="headerlink" title="解压下载好的rtmp直播模块"></a>解压下载好的rtmp直播模块</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">unzip nginx-http-flv-<span class="built_in">module</span>.zip</span><br></pre></td></tr></table></figure></li>
<li><h3 id="进入解压好的nginx下目录，并进行安装前的配置"><a href="#进入解压好的nginx下目录，并进行安装前的配置" class="headerlink" title="进入解压好的nginx下目录，并进行安装前的配置"></a>进入解压好的nginx下目录，并进行安装前的配置</h3><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">cd nginx-<span class="number">1.18</span><span class="number">.0</span></span><br><span class="line">./configure --prefix=<span class="regexp">/usr/</span>local/nginx-flv --add-<span class="built_in">module</span>=<span class="regexp">/home/</span>flv-tools/nginx-http-flv-<span class="built_in">module</span>-master</span><br><span class="line"># --prefix: 配置安装路径</span><br><span class="line">#--add-module: 添加安装插件</span><br></pre></td></tr></table></figure></li>
<li><h3 id="编译及安装"><a href="#编译及安装" class="headerlink" title="编译及安装"></a>编译及安装</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">make </span><br><span class="line">make install </span><br><span class="line">------------</span><br><span class="line">make &amp;&amp; make install </span><br></pre></td></tr></table></figure>

</li>
</ul>
<h3 id="配置文件相关"><a href="#配置文件相关" class="headerlink" title="配置文件相关"></a>配置文件相关</h3><ul>
<li><h3 id="修改配置文件"><a href="#修改配置文件" class="headerlink" title="修改配置文件"></a>修改配置文件</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">worker_processes  <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line">rtmp_auto_push on;</span><br><span class="line">rtmp_auto_push_reconnect 1s;</span><br><span class="line">rtmp_socket_dir /tmp;</span><br><span class="line"></span><br><span class="line">rtmp&#123;</span><br><span class="line">	out_queue <span class="number">4096</span>;</span><br><span class="line">	out_cork <span class="number">8</span>;</span><br><span class="line">	max_streams <span class="number">128</span>;</span><br><span class="line">	timeout 15s;</span><br><span class="line">	drop_idle_publisher 15s;</span><br><span class="line">	log_interval 5s;</span><br><span class="line">	log_size 1m;</span><br><span class="line">	server &#123;</span><br><span class="line">		listen 1935; # 推流端口</span><br><span class="line">		server_name zege;</span><br><span class="line">		</span><br><span class="line">		application live &#123;	# 配置推流地址</span><br><span class="line">			live on; # 打开推流</span><br><span class="line">			# gop_cache on;</span><br><span class="line">			# rtmp://123.123.123.123:1935/live/test</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">events &#123;</span><br><span class="line">    worker_connections  <span class="number">1024</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li><h3 id="配置文件http拉流部分"><a href="#配置文件http拉流部分" class="headerlink" title="配置文件http拉流部分"></a>配置文件http拉流部分</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">http &#123;</span><br><span class="line">	include       mime.types;</span><br><span class="line">	default_type  application/octet-stream;</span><br><span class="line">	sendfile        on;</span><br><span class="line">	keepalive_timeout  <span class="number">65</span>;</span><br><span class="line">	server &#123;</span><br><span class="line">		listen       8080; # 拉流通过8080去拉流</span><br><span class="line">		# http://123.123.123.123:8080/live/?port=1935&amp;stream=test</span><br><span class="line">		server_name  localhost;</span><br><span class="line">		location /live &#123;</span><br><span class="line">			flv_live on;</span><br><span class="line">			chunked_transfer_encoding  on;</span><br><span class="line">			add_header <span class="string">&#x27;Access-Control-Allow-Origin&#x27;</span> <span class="string">&#x27;*&#x27;</span>;</span><br><span class="line">			add_header <span class="string">&#x27;Access-Control-Allow-Credentials&#x27;</span> <span class="string">&#x27;true&#x27;</span>;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

</li>
</ul>
<h3 id="服务相关"><a href="#服务相关" class="headerlink" title="服务相关"></a>服务相关</h3><ul>
<li><h3 id="关闭旧有服务"><a href="#关闭旧有服务" class="headerlink" title="关闭旧有服务"></a>关闭旧有服务</h3><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">/usr/local/nginx-rtmp/sbin/nginx -s stop</span><br><span class="line">/usr/local/nginx-rtmp/sbin/nginx -s reload</span><br><span class="line"># 重启</span><br></pre></td></tr></table></figure></li>
<li><h3 id="开启新服务"><a href="#开启新服务" class="headerlink" title="开启新服务"></a>开启新服务</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/usr/local/nginx-flv/sbin/nginx -c /usr/local/nginx-flv/conf/nginx.conf</span><br></pre></td></tr></table></figure>
<code>记得打开阿里云的防火墙哦</code></li>
</ul>
<h3 id="推拉流地址"><a href="#推拉流地址" class="headerlink" title="推拉流地址"></a>推拉流地址</h3><ul>
<li><h3 id="推流地址"><a href="#推流地址" class="headerlink" title="推流地址"></a>推流地址</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rtmp:<span class="comment">//云主机的ip:端口/live/密钥</span></span><br></pre></td></tr></table></figure></li>
<li><h3 id="拉流地址"><a href="#拉流地址" class="headerlink" title="拉流地址"></a>拉流地址</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">http:<span class="comment">//云主机的ip:8080/live?port=端口&amp;app=live&amp;stream=密钥</span></span><br></pre></td></tr></table></figure>
</li>
</ul>
<hr>
<h2 id="Vue实现拉流"><a href="#Vue实现拉流" class="headerlink" title="Vue实现拉流"></a>Vue实现拉流</h2><ul>
<li><h3 id="安装flv-js开源工具，进行拉流，哔哩哔哩开源的拉流js"><a href="#安装flv-js开源工具，进行拉流，哔哩哔哩开源的拉流js" class="headerlink" title="安装flv.js开源工具，进行拉流，哔哩哔哩开源的拉流js"></a>安装flv.js开源工具，进行拉流，哔哩哔哩开源的拉流js</h3><code>video.js 对rtmp拉流</code><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cnpm install flv.js --save</span><br></pre></td></tr></table></figure></li>
<li><h3 id="导包"><a href="#导包" class="headerlink" title="导包"></a>导包</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> flv <span class="keyword">from</span> <span class="string">&#x27;flv.js&#x27;</span></span><br></pre></td></tr></table></figure></li>
<li><h3 id="构建页面标签，播放标签"><a href="#构建页面标签，播放标签" class="headerlink" title="构建页面标签，播放标签"></a>构建页面标签，播放标签</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;video id=<span class="string">&quot;videoElement&quot;</span> controls muted&gt;</span><br><span class="line">  	Your browser is too old which doesn<span class="string">&#x27;t support HTML5 video.</span></span><br><span class="line"><span class="string">&lt;/video&gt;</span></span><br></pre></td></tr></table></figure></li>
<li><h3 id="进行初始化"><a href="#进行初始化" class="headerlink" title="进行初始化"></a>进行初始化</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="title">mounted</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">    <span class="keyword">var</span> videoElement = <span class="built_in">document</span>.getElementById(<span class="string">&#x27;videoElement&#x27;</span>);</span><br><span class="line">    <span class="keyword">var</span> flvPlayer = flv.createPlayer(&#123;</span><br><span class="line">      type: <span class="string">&#x27;flv&#x27;</span>,</span><br><span class="line">      enableWorker: <span class="literal">true</span>,     <span class="comment">//浏览器端开启flv.js的worker,多进程运行flv.js</span></span><br><span class="line">      isLive: <span class="literal">true</span>,           <span class="comment">//直播模式</span></span><br><span class="line">      hasAudio: <span class="literal">false</span>,        <span class="comment">//关闭音频</span></span><br><span class="line">      hasVideo: <span class="literal">true</span>,</span><br><span class="line">      <span class="comment">// cors: true,</span></span><br><span class="line">      stashInitialSize: <span class="number">128</span>,</span><br><span class="line">      enableStashBuffer: <span class="literal">false</span>, <span class="comment">//播放flv时，设置是否启用播放缓存，只在直播起作用。</span></span><br><span class="line">      <span class="comment">// url: &#x27;http://192.168.2.234/flv/323223618780001&#x27;</span></span><br><span class="line">      <span class="comment">// url: &#x27;http://39.105.79.238:8080/live?port=1935&amp;app=live&amp;stream=test&#x27;</span></span><br><span class="line">      url: <span class="string">&#x27;http://47.93.48.154:8080/live?port=1935&amp;app=live&amp;stream=test&#x27;</span></span><br><span class="line">    &#125;)</span><br><span class="line">    flvPlayer.attachMediaElement(videoElement);</span><br><span class="line">    flvPlayer.load();</span><br><span class="line">    flvPlayer.play();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<hr>
<h3 id="这样一个简易视频直播就轻松实现啦"><a href="#这样一个简易视频直播就轻松实现啦" class="headerlink" title="这样一个简易视频直播就轻松实现啦"></a>这样一个简易视频直播就轻松实现啦</h3><h3 id="欢迎广大网友们前来留言哦"><a href="#欢迎广大网友们前来留言哦" class="headerlink" title="欢迎广大网友们前来留言哦"></a>欢迎广大网友们前来留言哦</h3><h3 id="我撤啦-拜拜喽小可爱们"><a href="#我撤啦-拜拜喽小可爱们" class="headerlink" title="我撤啦 拜拜喽小可爱们~"></a>我撤啦 拜拜喽小可爱们~</h3><p><img src="https://i.loli.net/2021/02/05/wB5ZX7QqmldRsFG.png" alt="拜拜.png"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Z_SiTong</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://zhang-sitong.gitee.io/blogs/lz_12/">https://zhang-sitong.gitee.io/blogs/lz_12/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://zhang-sitong.gitee.io/blogs" target="_blank">欢迎来到小张的博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/blogs/tags/vue/">vue</a></div><div class="post_share"><div class="social-share" data-image="https://i.loli.net/2021/02/05/tKdkzYVFgSc7J8A.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/blogs/lz_13/"><img class="prev-cover" src="https://i.loli.net/2021/02/07/fpuA4F1BEjGbWo9.jpg" onerror="onerror=null;src='/blogs/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">docker操作容器、镜像 / dockerfile</div></div></a></div><div class="next-post pull-right"><a href="/blogs/lz_11/"><img class="next-cover" src="https://i.loli.net/2021/02/04/aKdLr2JnHktTNFZ.jpg" onerror="onerror=null;src='/blogs/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">无限极分类 (自关联+递归)</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/blogs/lz_1/" title="Vue拦截器"><img class="cover" src="https://i.loli.net/2021/01/27/m1oxUzcOLyw8vjf.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-01-25</div><div class="title">Vue拦截器</div></div></a></div><div><a href="/blogs/lz_2/" title="Vue路由钩子"><img class="cover" src="https://i.loli.net/2021/01/27/4LRmhlz3OEDHtg6.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-01-26</div><div class="title">Vue路由钩子</div></div></a></div><div><a href="/blogs/lz_3/" title="Vue父子组件 子父组件"><img class="cover" src="https://i.loli.net/2021/01/27/HUmdSQoOPWMT9jz.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-01-27</div><div class="title">Vue父子组件 子父组件</div></div></a></div><div><a href="/blogs/lz_7/" title="axios封装"><img class="cover" src="https://i.loli.net/2021/01/31/ROLikGyWvwSN3T6.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-01-31</div><div class="title">axios封装</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src="/blogs/img/%E5%8D%9A%E5%AE%A2%E5%A4%B4%E5%83%8F.jpg" onerror="this.onerror=null;this.src='/blogs/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">Z_SiTong</div><div class="author-info__description"></div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/blogs/archives/"><div class="headline">文章</div><div class="length-num">29</div></a></div><div class="card-info-data-item is-center"><a href="/blogs/tags/"><div class="headline">标签</div><div class="length-num">12</div></a></div><div class="card-info-data-item is-center"><a href="/blogs/categories/"><div class="headline">分类</div><div class="length-num">12</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is my blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9B%B4%E6%92%AD"><span class="toc-number">1.</span> <span class="toc-text">直播</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%B4%E6%92%AD%EF%BC%9A%E6%B5%81%E5%BC%8F%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE%EF%BC%8C%E4%BC%A0%E8%BE%93%E9%9D%9E%E5%B8%B8%E7%9F%AD%E7%9A%84%E4%B8%80%E5%B0%8F%E6%88%AA%E8%A7%86%E9%A2%91"><span class="toc-number">1.1.</span> <span class="toc-text">直播：流式传输协议，传输非常短的一小截视频</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A7%82%E7%9C%8B%E7%9B%B4%E6%92%AD"><span class="toc-number">1.2.</span> <span class="toc-text">观看直播</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8D%8F%E8%AE%AE"><span class="toc-number">1.3.</span> <span class="toc-text">协议</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8E%A8%E6%B5%81%EF%BC%88%E4%BD%BF%E7%94%A8OBS%EF%BC%89"><span class="toc-number">1.4.</span> <span class="toc-text">推流（使用OBS）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8B%89%E6%B5%81%EF%BC%88%E4%BD%BF%E7%94%A8%E6%B5%8F%E8%A7%88%E5%99%A8%E6%88%96Vlc%EF%BC%89"><span class="toc-number">1.5.</span> <span class="toc-text">拉流（使用浏览器或Vlc）</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9B%B4%E6%92%AD%E5%9F%BA%E6%9C%AC%E6%B5%81%E7%A8%8B%E5%9B%BE"><span class="toc-number">2.</span> <span class="toc-text">直播基本流程图</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B8%B8%E8%A7%81%E7%9A%84%E7%9B%B4%E6%92%AD%E5%8D%8F%E8%AE%AE"><span class="toc-number">3.</span> <span class="toc-text">常见的直播协议</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#RTMP%E7%9B%B4%E6%92%AD%E5%8D%8F%E8%AE%AE"><span class="toc-number">3.1.</span> <span class="toc-text">RTMP直播协议</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BC%98%E7%82%B9"><span class="toc-number">3.2.</span> <span class="toc-text">优点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BC%BA%E7%82%B9"><span class="toc-number">3.3.</span> <span class="toc-text">缺点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#HTTP-FLV%E7%9B%B4%E6%92%AD%E5%8D%8F%E8%AE%AE"><span class="toc-number">3.4.</span> <span class="toc-text">HTTP-FLV直播协议</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BC%98%E7%82%B9-1"><span class="toc-number">3.5.</span> <span class="toc-text">优点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BC%BA%E7%82%B9-1"><span class="toc-number">3.6.</span> <span class="toc-text">缺点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#HLS%E7%9B%B4%E6%92%AD%E5%8D%8F%E8%AE%AE"><span class="toc-number">3.7.</span> <span class="toc-text">HLS直播协议</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BC%98%E7%82%B9-2"><span class="toc-number">3.8.</span> <span class="toc-text">优点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BC%BA%E7%82%B9-2"><span class="toc-number">3.9.</span> <span class="toc-text">缺点</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%91%E4%B8%BB%E6%9C%BA%E6%90%AD%E5%BB%BA%E7%9B%B4%E6%92%AD"><span class="toc-number">4.</span> <span class="toc-text">云主机搭建直播</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%8E%AF%E5%A2%83%E9%83%A8%E7%BD%B2%E7%9B%B8%E5%85%B3"><span class="toc-number">4.1.</span> <span class="toc-text">环境部署相关</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E8%BD%AF%E4%BB%B6%E7%9A%84%E5%AD%98%E5%82%A8%E4%BD%8D%E7%BD%AE"><span class="toc-number">4.2.</span> <span class="toc-text">创建软件的存储位置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%8B%E8%BD%BDnginx"><span class="toc-number">4.3.</span> <span class="toc-text">下载nginx</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%8B%E8%BD%BD%E7%9B%B4%E6%92%AD%E6%A8%A1%E5%9D%97"><span class="toc-number">4.4.</span> <span class="toc-text">下载直播模块</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A7%A3%E5%8E%8B%E4%B8%8B%E8%BD%BD%E5%A5%BD%E7%9A%84nginx"><span class="toc-number">4.5.</span> <span class="toc-text">解压下载好的nginx</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%A7%A3%E5%8E%8B%E4%B8%8B%E8%BD%BD%E5%A5%BD%E7%9A%84rtmp%E7%9B%B4%E6%92%AD%E6%A8%A1%E5%9D%97"><span class="toc-number">4.6.</span> <span class="toc-text">解压下载好的rtmp直播模块</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%9B%E5%85%A5%E8%A7%A3%E5%8E%8B%E5%A5%BD%E7%9A%84nginx%E4%B8%8B%E7%9B%AE%E5%BD%95%EF%BC%8C%E5%B9%B6%E8%BF%9B%E8%A1%8C%E5%AE%89%E8%A3%85%E5%89%8D%E7%9A%84%E9%85%8D%E7%BD%AE"><span class="toc-number">4.7.</span> <span class="toc-text">进入解压好的nginx下目录，并进行安装前的配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BC%96%E8%AF%91%E5%8F%8A%E5%AE%89%E8%A3%85"><span class="toc-number">4.8.</span> <span class="toc-text">编译及安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%9B%B8%E5%85%B3"><span class="toc-number">4.9.</span> <span class="toc-text">配置文件相关</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">4.10.</span> <span class="toc-text">修改配置文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6http%E6%8B%89%E6%B5%81%E9%83%A8%E5%88%86"><span class="toc-number">4.11.</span> <span class="toc-text">配置文件http拉流部分</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9C%8D%E5%8A%A1%E7%9B%B8%E5%85%B3"><span class="toc-number">4.12.</span> <span class="toc-text">服务相关</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B3%E9%97%AD%E6%97%A7%E6%9C%89%E6%9C%8D%E5%8A%A1"><span class="toc-number">4.13.</span> <span class="toc-text">关闭旧有服务</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%80%E5%90%AF%E6%96%B0%E6%9C%8D%E5%8A%A1"><span class="toc-number">4.14.</span> <span class="toc-text">开启新服务</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8E%A8%E6%8B%89%E6%B5%81%E5%9C%B0%E5%9D%80"><span class="toc-number">4.15.</span> <span class="toc-text">推拉流地址</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8E%A8%E6%B5%81%E5%9C%B0%E5%9D%80"><span class="toc-number">4.16.</span> <span class="toc-text">推流地址</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8B%89%E6%B5%81%E5%9C%B0%E5%9D%80"><span class="toc-number">4.17.</span> <span class="toc-text">拉流地址</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Vue%E5%AE%9E%E7%8E%B0%E6%8B%89%E6%B5%81"><span class="toc-number">5.</span> <span class="toc-text">Vue实现拉流</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85flv-js%E5%BC%80%E6%BA%90%E5%B7%A5%E5%85%B7%EF%BC%8C%E8%BF%9B%E8%A1%8C%E6%8B%89%E6%B5%81%EF%BC%8C%E5%93%94%E5%93%A9%E5%93%94%E5%93%A9%E5%BC%80%E6%BA%90%E7%9A%84%E6%8B%89%E6%B5%81js"><span class="toc-number">5.1.</span> <span class="toc-text">安装flv.js开源工具，进行拉流，哔哩哔哩开源的拉流js</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AF%BC%E5%8C%85"><span class="toc-number">5.2.</span> <span class="toc-text">导包</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9E%84%E5%BB%BA%E9%A1%B5%E9%9D%A2%E6%A0%87%E7%AD%BE%EF%BC%8C%E6%92%AD%E6%94%BE%E6%A0%87%E7%AD%BE"><span class="toc-number">5.3.</span> <span class="toc-text">构建页面标签，播放标签</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%9B%E8%A1%8C%E5%88%9D%E5%A7%8B%E5%8C%96"><span class="toc-number">5.4.</span> <span class="toc-text">进行初始化</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%99%E6%A0%B7%E4%B8%80%E4%B8%AA%E7%AE%80%E6%98%93%E8%A7%86%E9%A2%91%E7%9B%B4%E6%92%AD%E5%B0%B1%E8%BD%BB%E6%9D%BE%E5%AE%9E%E7%8E%B0%E5%95%A6"><span class="toc-number">5.5.</span> <span class="toc-text">这样一个简易视频直播就轻松实现啦</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%AC%A2%E8%BF%8E%E5%B9%BF%E5%A4%A7%E7%BD%91%E5%8F%8B%E4%BB%AC%E5%89%8D%E6%9D%A5%E7%95%99%E8%A8%80%E5%93%A6"><span class="toc-number">5.6.</span> <span class="toc-text">欢迎广大网友们前来留言哦</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%88%91%E6%92%A4%E5%95%A6-%E6%8B%9C%E6%8B%9C%E5%96%BD%E5%B0%8F%E5%8F%AF%E7%88%B1%E4%BB%AC"><span class="toc-number">5.7.</span> <span class="toc-text">我撤啦 拜拜喽小可爱们~</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blogs/lz_28/" title="多因子登录基础知识点"><img src="https://i.loli.net/2021/04/19/T9cDNdmovulPEbL.jpg" onerror="this.onerror=null;this.src='/blogs/img/404.jpg'" alt="多因子登录基础知识点"/></a><div class="content"><a class="title" href="/blogs/lz_28/" title="多因子登录基础知识点">多因子登录基础知识点</a><time datetime="2019-04-19T12:08:59.000Z" title="发表于 2019-04-19 20:08:59">2019-04-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blogs/lz_27/" title="基于Docker安装关系型数据库PostgrelSQL替代Mysql"><img src="https://i.loli.net/2021/04/19/QRXbxEvnLpBHuzI.jpg" onerror="this.onerror=null;this.src='/blogs/img/404.jpg'" alt="基于Docker安装关系型数据库PostgrelSQL替代Mysql"/></a><div class="content"><a class="title" href="/blogs/lz_27/" title="基于Docker安装关系型数据库PostgrelSQL替代Mysql">基于Docker安装关系型数据库PostgrelSQL替代Mysql</a><time datetime="2019-04-14T01:42:58.000Z" title="发表于 2019-04-14 09:42:58">2019-04-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blogs/lz_26/" title="json与pickle"><img src="https://i.loli.net/2021/04/13/DtnL4OVQM7bZjId.jpg" onerror="this.onerror=null;this.src='/blogs/img/404.jpg'" alt="json与pickle"/></a><div class="content"><a class="title" href="/blogs/lz_26/" title="json与pickle">json与pickle</a><time datetime="2019-04-12T07:48:41.000Z" title="发表于 2019-04-12 15:48:41">2019-04-12</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blogs/lz_25/" title="集合(set)的用法和使用场景，以及底层去重算法"><img src="https://i.loli.net/2021/04/08/Ji5dTUKsnoGjRBz.jpg" onerror="this.onerror=null;this.src='/blogs/img/404.jpg'" alt="集合(set)的用法和使用场景，以及底层去重算法"/></a><div class="content"><a class="title" href="/blogs/lz_25/" title="集合(set)的用法和使用场景，以及底层去重算法">集合(set)的用法和使用场景，以及底层去重算法</a><time datetime="2019-04-06T02:48:41.000Z" title="发表于 2019-04-06 10:48:41">2019-04-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blogs/lz_24/" title="openLDAP"><img src="https://i.loli.net/2021/04/07/nLeJybVMHwFNj7G.jpg" onerror="this.onerror=null;this.src='/blogs/img/404.jpg'" alt="openLDAP"/></a><div class="content"><a class="title" href="/blogs/lz_24/" title="openLDAP">openLDAP</a><time datetime="2019-03-31T08:52:13.000Z" title="发表于 2019-03-31 16:52:13">2019-03-31</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2021 <i style="color:#FF6A6A;animation: announ_animation 0.8s linear infinite;" class="fa fa-heartbeat"></i> Z_SiTong</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/blogs/js/utils.js"></script><script src="/blogs/js/main.js"></script><script src="/blogs/js/search/local-search.js"></script><div class="js-pjax"></div><script src="https://cdn.jsdelivr.net/gh/lete114/CDN/Sum/sakura.js"></script><script src="https://cdn.jsdelivr.net/gh/lete114/CDN/Sum/title.js"></script>null<script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>